package qqq.aop.test1;//package com.hsc.www;
//
//
//import org.springframework.aop.AfterAdvice;
//import org.springframework.aop.BeforeAdvice;
//import org.springframework.aop.framework.ProxyFactory;
//
////class AdviseMethodInterceptor implements MethodInterceptor {
////    @Override
////    public Object invoke(MethodInvocation methodInvocation) throws Throwable {
////        System.out.println("方法执行之前：" + methodInvocation.getMethod().toString());
////        Object result = methodInvocation.proceed();
////        System.out.println("方法执行之后：" + methodInvocation.getMethod().toString());
////        return result;
////    }
////}
////
////class BeforeAdvice implements MethodBeforeAdvice {
////    @Override
////    public void before(Method method, Object[] args, Object target) throws Throwable {
////        System.out.println("前置增强====================》");
////    }
////}
////
////
////class AfterAdvice implements AfterReturningAdvice {
////    @Override
////    public void afterReturning(Object returnValue, Method method, Object[] args, Object target) throws Throwable {
////        System.out.println("后置增强==================》");
////    }
////}
////
////class ExceptionAdvice implements ThrowsAdvice {
////
////    public void afterThrowing(Method method, Object[] args, Object target, Exception ex) {
////        System.out.println("异常====================》");
////    }
////}
////
////
////class User {
////    public void helloWorld() {
////        System.out.println("你好！");
////    }
////
////    public void Error() {
////        throw new RuntimeException("Error");
////    }
////}
//
//
//public class Main1 {
//
//    public static void main(String[] args) {
//        ProxyFactory proxyFactory = new ProxyFactory();
//        proxyFactory.setTarget(new User());
//        proxyFactory.addAdvice(new AdviseMethodInterceptor());
//        proxyFactory.addAdvice(new BeforeAdvice());
//        proxyFactory.addAdvice(new AfterAdvice());
//        proxyFactory.addAdvice(new ExceptionAdvice());
//
//        User proxyUser = (User) proxyFactory.getProxy();
//        proxyUser.helloWorld();
//        proxyUser.Error();
//    }
//}
